<?php
class EventCategory extends EventsAppModel {

	var $name = 'EventCategory';
	//var $actsAs = array('Tree');

	var $validate = array(
			'name' => array(
				'uniqueName'=>array(
					'rule' => 'isUnique',
					'message' => 'This category name has already been taken.'
				),
				'nameNotEmpty'=>array(
					'rule' => VALID_NOT_EMPTY,
					'message' => 'The category name should not be blank.'
				)
			)
	);

	/*
	var $belongsTo = array(
		'User' => array(
		'className' => 'Users.User',
		'foreignKey' => 'user_id'
		)
	);
	*/

	var $hasMany = array(
		'Event' => array(
			'className' => 'Events.Event',
			'foreignKey' => 'event_category_id',
			'dependent' => true
		)
	);
	
	var $order = array("EventCategory.name"=>"ASC");

	function getOptions()
	{
		$event_categories = $this->find('list',array('fields'=>array('EventCategory.id','EventCategory.name'),'recursive'=>-1));
		return $event_categories;
	}
			
}
?>